#Twisted Shootout
#Copyright (C) 2007 Han Dao
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

#You can contact the author at wikipediankiba@gmail.com

import pygame

class TextType:
	def __init__(self,text):
		self.text = text
		self.string = ''
		self.switch = False
	def typing(self,k):
		if self.switch == True:
		     if k.type == pygame.KEYDOWN:
			if k.key == pygame.K_a:
			    self.string = self.string + "a"
			elif k.key == pygame.K_b:
			    self.string = self.string + "b"
			elif k.key == pygame.K_c:
			    self.string = self.string + "c"
			elif k.key == pygame.K_d:
			    self.string = self.string + "d"
			elif k.key == pygame.K_e:
			    self.string = self.string + "e"
			elif k.key == pygame.K_f:
			    self.string = self.string + "f"
			elif k.key == pygame.K_g:
			    self.string = self.string + "g"
			elif k.key == pygame.K_h:
			    self.string = self.string + "h"
			elif k.key == pygame.K_i:
			    self.string = self.string + "i"
			elif k.key == pygame.K_j:
			    self.string = self.string + "j"
			elif k.key == pygame.K_k:
			    self.string = self.string + "k"
			elif k.key == pygame.K_l:
			    self.string = self.string + "l"
			elif k.key == pygame.K_m:
			    self.string = self.string + "m"
			elif k.key == pygame.K_n:
			    self.string = self.string + "n"
			elif k.key == pygame.K_o:
			    self.string = self.string + "o"
			elif k.key == pygame.K_p:
			    self.string = self.string + "p"
			elif k.key == pygame.K_q:
			    self.string = self.string + "q"
			elif k.key == pygame.K_r:
			    self.string = self.string + "r"
			elif k.key == pygame.K_s:
			    self.string = self.string + "s"
			elif k.key == pygame.K_t:
			    self.string = self.string + "t"
			elif k.key == pygame.K_u:
			    self.string = self.string + "u"
			elif k.key == pygame.K_v:
			    self.string = self.string + "v"
			elif k.key == pygame.K_w:
			    self.string = self.string + "w"
			elif k.key == pygame.K_y:
			    self.string = self.string + "y"
			elif k.key == pygame.K_z:
			    self.string = self.string + "z"
	def delete(self,k):
		if self.switch == True:
		    if k.type == pygame.KEYDOWN:
			if k.key == pygame.K_BACKSPACE:
			      self.string = self.string[:-1]
	def enter(self,k):
		if self.switch == True:
		    if k.type == pygame.KEYDOWN:
			if k.key == pygame.K_RETURN:
			      self.switch = 3
	def datareturn(self):
	    if self.string != '':
		return self.string
	    else:
		return False